package o;

import android.text.TextUtils;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale;
import java.util.Stack;

public class bca {
    public static void ˏ(Stack<String> stack, ArrayList<String> arrayList, bce o_bce) {
        String str = (String) stack.pop();
        if (!TextUtils.isEmpty(str)) {
            File file = new File(str);
            if (file.canRead()) {
                Object obj;
                Iterator it = arrayList.iterator();
                while (it.hasNext()) {
                    try {
                        if (file.getCanonicalPath().startsWith(new File((String) it.next()).getCanonicalPath())) {
                            obj = 1;
                            break;
                        }
                    } catch (IOException e) {
                        bbn.ˎ.ˊ("ApkSearchUtils", "can not getCanonicalPath");
                    }
                }
                obj = null;
                if (obj != null) {
                    return;
                }
                if (file.isFile() && ((str.toLowerCase(Locale.ENGLISH).endsWith(".apk") || (ॱ(str) && str.toLowerCase(Locale.ENGLISH).endsWith(".apk.1"))) && file.canWrite())) {
                    o_bce.ˊ(file, str);
                } else if (file.isDirectory()) {
                    o_bce.ˋ(str);
                    ˏ(file, stack);
                }
            }
        }
    }

    private static boolean ॱ(String str) {
        boolean z = false;
        if (!TextUtils.isEmpty(str)) {
            for (CharSequence contains : bbw.ˊ) {
                z = str.contains(contains);
                if (z) {
                    break;
                }
            }
        }
        return z;
    }

    private static void ˏ(File file, Stack<String> stack) {
        int i;
        int i2 = 0;
        File[] listFiles = file.listFiles();
        if (listFiles == null) {
            i = 0;
        } else {
            i = listFiles.length;
        }
        if (listFiles != null) {
            while (i2 < i) {
                stack.push(listFiles[i2].getAbsolutePath());
                i2++;
            }
        }
    }
}
